<template>
    <transition name='fade'>
        <div class="shadow" :style="{ backgroundColor: props.shadowColor }" v-if="show">
            <slot></slot>
        </div>
    </transition>
</template>
  
<script setup>
import { watch, ref } from 'vue'

const props = defineProps({
    open: {
        type: Boolean,
        default: false
    },
    shadowColor: {
        type: String,
        default: 'rgba(0, 0, 0, 0.5)'
    }
});

const show = ref(props.open)
watch(() => props.open, (val) => {
    show.value = val;
});

</script>
  
<style scoped>
.fade-enter-active,
.fade-leave-active {
    transition: opacity .35s;
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}

.shadow {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
}
</style>
  